const Router = require('@koa/router')
const Auth = require('../middlewares/auth')
const {
    generateToken,
    verifyToken
} = require('../core/util')

const tokenRouter = new Router({
    //设置路由前缀 /token
    prefix: '/token',
})

//检测用户名、密码，返回token接口
tokenRouter.post('/', async ctx => {
    const { username, password } = ctx.request.body;

    const token 

})

//检测token有效性
tokenRouter.post('/verify', async ctx => {
    const token = ctx.request.body.token;
    const isValid = Auth.verifyToken(token);

    ctx.body = {
        isValid
    }
})